define((['jquery']),()=>{
    function loginLoad(){
        var username = document.querySelector('.username')
        var password =document.querySelector('.password')
        var login= document.querySelector('.login_login')
        var check=document.querySelector('.checkbox')
        var span=document.querySelector('.spanB')
        var spanA=document.querySelector('.spanA')
        var us= localStorage.getItem('username',username.value)
        var pa=localStorage.getItem('password',password.value)
        login.onclick=()=>{
          if(username.value==''||password.value==''||check.checked==false){
            alert('请仔细阅读并勾选以下协议')
          }else{
            if(username.value==us&&password.value==pa){
                alert('用户名正确')
                location.href=('../index.html')
                localStorage.setItem('username',username.value)
            }else{
                alert('登录失败，请检查用户名密码是否正确')
            }
    
          }
    
        }
        // 正则
        var yh=/^[\u2E80-\u9FFF]+$/
        var my=/^[a-z0-9_-]{6,18}$/
        username.onfocus = function(){
            span.innerHTML = '请输入正确的用户名'
        }
        username.onblur = function(){
            if(yh.test(username.value)){
                span.innerHTML = '√'
            }else{
                span.innerHTML = '用户名格式错误'  
            }
        }
    
    
        password.onfocus = function(){
            spanA.innerHTML = '请输入正确的密码'
        }
        password.onblur = function(){
            if(my.test(password.value)){
                spanA.innerHTML = '√'
            }else{
                spanA.innerHTML = '密码格式错误'  
            }
        }
    }
    return{
        loginLoad:loginLoad
    }
})
